<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Internal Drug Manage</title>

    <!-- Custom fonts for this template-->
    <link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
    <link
        href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i"
        rel="stylesheet">

    <!-- Custom styles for this template-->
    <link href="css/sb-admin-2.min.css" rel="stylesheet">

    <!-- Custom styles for this page -->
    <link href="vendor/datatables/dataTables.bootstrap4.min.css" rel="stylesheet">

</head>

<body id="page-top">

    <!-- Page Wrapper -->
    <div id="wrapper">   
        <!-- Sidebar -->
        <!-- Sidebar -->
        <ul class="navbar-nav bg-gradient-primary sidebar sidebar-dark accordion" id="accordionSidebar">

            <!-- Sidebar - Brand -->
            <a class="sidebar-brand d-flex align-items-center justify-content-center">
                <div class="sidebar-brand-icon rotate-n-15">
                    <i class="fas fa-laugh-wink"></i>
                </div>
                <div class="sidebar-brand-text mx-3">卖方管理员</div>
            </a>

            <!-- Divider -->
            <hr class="sidebar-divider my-0">

            <!-- Nav Item - Dashboard -->
            <li class="nav-item">
                <a class="nav-link" id="management">
                    <i class="fas fa-fw fa-wrench"></i>
                    <span>User Management</span></a>
            </li>

            <!-- Divider -->
            <hr class="sidebar-divider">

            <!-- Nav Item - Dashboard -->
            <li class="nav-item">
                <a class="nav-link" id="request">
                    <i class="fas fa-fw fa-table"></i>
                    <span>Registeration Request</span></a>
            </li>

            <!-- Divider -->
            <hr class="sidebar-divider">

            <!-- Nav Item - Dashboard -->
            <li class="nav-item">
                <a class="nav-link" id="buyer_application">
                    <i class="fas fa-fw fa-table"></i>
                    <span>Buyer Application</span></a>
            </li>

            <!-- Divider -->
            <hr class="sidebar-divider d-none d-md-block">

            <li class="nav-item active">
                <a class="nav-link" id="medical">
                    <i class="fas fa-fw fa-cog"></i>
                    <span>Medical Management</span></a>
            </li>

            <!-- Divider -->
            <hr class="sidebar-divider d-none d-md-block">

            <!-- Sidebar Toggler (Sidebar) -->
            <div class="text-center d-none d-md-inline">
                <button class="round ed-circle border-0" id="sidebarToggle"></button>
            </div>

        </ul>
        <!-- End of Sidebar -->

        <!-- Content Wrapper -->
        <div id="content-wrapper" class="d-flex flex-column">

            <!-- Main Content -->
            <div id="content">
                 <!-- Topbar -->
                 <nav class="navbar navbar-expand navbar-light bg-white topbar mb-4 static-top shadow">

                    <!-- Sidebar Toggle (Topbar) -->
                    <button id="sidebarToggleTop" class="btn btn-link d-md-none rounded-circle mr-3">
                        <i class="fa fa-bars"></i>
                    </button>

                    <h4 class="m-0 font-weight-bold text-primary">Internal Drug Manage</h4>

                    <!-- Topbar Navbar -->
                    <ul class="navbar-nav ml-auto">

                        <div class="topbar-divider d-none d-sm-block"></div>

                        <!-- Nav Item - User Information -->
                        <li class="nav-item dropdown no-arrow">
                            <a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button"
                                data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                <span class="mr-2 d-none d-lg-inline text-gray-600 small" id="name"></span>
                                <img class="img-profile rounded-circle"
                                    src="img/undraw_profile.svg">
                            </a>
                            <!-- Dropdown - User Information -->
                            <div class="dropdown-menu dropdown-menu-right shadow animated--grow-in"
                                aria-labelledby="userDropdown">
                                <a class="dropdown-item" id="settings">
                                    <i class="fas fa-cogs fa-sm fa-fw mr-2 text-gray-400"></i>
                                    Settings
                                </a>
                                <div class="dropdown-divider"></div>
                                <a class="dropdown-item" href="#" data-toggle="modal" data-target="#logoutModal">
                                    <i class="fas fa-sign-out-alt fa-sm fa-fw mr-2 text-gray-400"></i>
                                    Logout
                                </a>
                            </div>
                        </li>

                    </ul>

                </nav>
                <!-- End of Topbar -->
                <!-- /.container-fluid -->

            <!-- End of Main Content -->
        <!-- End of Content Wrapper -->

    </div>
    <!-- End of Page Wrapper -->

                    <!-- Begin Page Content -->
                    <div class="container-fluid">

    
                        <!-- DataTales Example -->
                        <div class="card shadow mb-4">
                            <div class="card-header py-3">
                                <h6 class="m-0 font-weight-bold text-primary">Internal Drug</h6>
                            </div>
                            <div class="card-body">
                                <div class="table-responsive">
                                    <table class="table table-bordered" id="drug-table" width="100%" cellspacing="0">
                                        <thead>
                                            <tr>
                                                <th>Enterprise drug code</th>
                                                <th>Drug name</th>
                                                <th>Drug ID</th>
                                                <th>End date</th>
                                                <th>Update date</th>
                                                <th>Creation date</th>
                                                <th>State of drug</th>
                                                <th>Store number</th>
                                                <th>Seller Oid</th>
                                                <th>Unit price</th>
                                                <th>Manufacturer Oid</th>
                                                <th>Is manufacturer authorized</th>
                                                <th>Corresponding state</th>
                                                <th>Opreation</th>
                                            </tr>
                                        </thead>
                                        <tfoot>
                                            <tr>
                                                <th>Enterprise drug code</th>
                                                <th>Drug name</th>
                                                <th>Drug ID</th>
                                                <th>End date</th>
                                                <th>Update date</th>
                                                <th>Creation date</th>
                                                <th>State of drug</th>
                                                <th>Store number</th>
                                                <th>Seller Oid</th>
                                                <th>Unit price</th>
                                                <th>Manufacturer Oid</th>
                                                <th>Is manufacturer authorized</th>
                                                <th>Corresponding state</th>
                                                <th>Opreation</th>
                                            </tr>
                                        </tfoot>
                                        <tbody id="tbody-drug">
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
    
                    </div>
                    <!-- /.container-fluid -->  
                    
                    <!-- Modal -->
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title" id="myModalLabel">新增</h4>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">&times;</span></button>
                    </div>
                    <div class="modal-body">
                        <div class="form-group">
                            <input type="text" class="form-control" id="enterprise_drug_code" placeholder="药品内部代码">
                        </div>
                        <div class="form-group">
                            <input type="text" class="form-control" id="drug_name" placeholder="药品名称">
                        </div>
                        <div class="form-group">
                            <input type="text" class="form-control" id="drug_id" placeholder="药品ID">
                        </div>
                        <div class="form-group">
                            <input type="text" class="form-control" id="end_date" placeholder="有效期">
                        </div>
                        <div class="form-group">
                            <input type="text" class="form-control" id="update_date" placeholder="更新日期">
                        </div>
                        <div class="form-group">
                            <input type="text" class="form-control" id="creation_date" placeholder="生产日期">
                        </div>
                        <div class="form-group">
                            <input type="text" class="form-control" id="state_of_drug" placeholder="药品状态">
                        </div>
                        <div class="form-group">
                            <input type="text" class="form-control" id="store_num" placeholder="库存">
                        </div>
                        <div class="form-group">
                            <input type="text" class="form-control" id="oid_seller" placeholder="卖方ID">
                        </div>
                        <div class="form-group">
                            <input type="text" class="form-control" id="unit_price" placeholder="协商价格">
                        </div>
                        <div class="form-group">
                            <input type="text" class="form-control" id="oid_manufacturer" placeholder="厂商ID">
                        </div>
                         <!-- <div class="form-group">
                            <input type="text" class="form-control" id="is_manufacturer_authorized" placeholder="是否为机构授权">
                        </div> -->
                        <div class="form-group">
                            <input type="text" class="form-control" id="corresponding_state" placeholder="相关状态">
                        </div> 
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button" class="btn btn-primary" id="save">保存</button>
                    </div>
                </div>
            </div>
        </div>

         <!-- Modal -->
         <div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title" id="myModalLabel">修改管理员信息</h4>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">&times;</span></button>
                    </div>
                    <div class="modal-body">
                        <div class="form-group">
                            <table style="border: 1;width: 450px;">
                                <tr>
                                <td style="width: 15%;"><span class="mr-2 d-none d-lg-inline text-gray-600 small">ID</span></td>
                                <td style="width: 85%;"><input type="text" class="form-control" id="uid" placeholder="ID"></td>
                                </tr>
                            </table>
                        </div>
                         
                        <div class="form-group">
                            <table style="border: 1;width: 450px;">
                                <tr>
                                <td style="width: 15%;"><span class="mr-2 d-none d-lg-inline text-gray-600 small">用户名</span></td>
                                <td style="width: 85%;"><input type="text" class="form-control" id="user_name" placeholder="用户名"></td>
                                </tr>
                            </table>    
                        </div>
                        <div class="form-group">
                            <table style="border: 1;width: 450px;">
                                <tr>
                                <td style="width: 15%;"><span class="mr-2 d-none d-lg-inline text-gray-600 small">机构ID</td>
                                <td style="width: 85%;"><input type="text" class="form-control" id="oid" placeholder="机构ID"></td>
                                </tr>
                            </table>    
                        </div>
                        <div class="form-group">
                            <table style="border: 1;width: 450px;">
                                <tr>
                                <td style="width: 15%;"><span class="mr-2 d-none d-lg-inline text-gray-600 small">用户权限</span></td>
                                <td style="width: 85%;"><input type="text" class="form-control" id="user_authority" placeholder="用户权限"></td>
                                </tr>
                            </table>    
                        </div>
                         
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button" class="btn btn-primary" id="save2">保存</button>
                    </div>
                </div>
            </div>
        </div>
                    
                </div> 
    
    <!-- Scroll to Top Button-->
    <a class="scroll-to-top rounded" href="#page-top">
        <i class="fas fa-angle-up"></i>
    </a>

    <!-- Logout Modal-->
    <div class="modal fade" id="logoutModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
        aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="exampleModalLabel">Ready to Leave?</h5>
                    <button class="close" type="button" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">×</span>
                    </button>
                </div>
                <div class="modal-body">Select "Logout" below if you are ready to end your current session.</div>
                <div class="modal-footer">
                    <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
                    <a class="btn btn-primary" href="login.html">Logout</a>
                </div>
            </div>
        </div>
    </div>

    <!-- Bootstrap core JavaScript-->
    <script src="vendor/jquery/jquery.min.js"></script>
    <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

    <!-- Core plugin JavaScript-->
    <script src="vendor/jquery-easing/jquery.easing.min.js"></script>

    <!-- Custom scripts for all pages-->
    <script src="js/sb-admin-2.min.js"></script>

     <!-- Page level plugins -->
     <script src="vendor/datatables/jquery.dataTables.min.js"></script>
     <script src="vendor/datatables/dataTables.bootstrap4.min.js"></script>
 
     <!-- Page level custom scripts -->
     <script src="js/demo/datatables-demo.js"></script>
     <script src="plugin/handlebars-v3.0.1.js"></script>

<script id="tpl" type="text/x-handlebars-template">
        {{#each func}}
        <button type="button" class="btn btn-{{this.type}} btn-sm" onclick="{{this.fn}}">{{this.name}}</button>
        {{/each}}
</script>

<script>
    var table;
    var editFlag=false;
    $(document).ready(function (ev) {
        var tpl = $("#tpl").html();
        //预编译模板
        var template = Handlebars.compile(tpl);
        table=$('#drug-table').DataTable(
        {
            "ajax":{
            "url":"http://210.30.97.103:20305/admin/companydrug",
            "dataType":"json",
            "type":"get",
            "data":{"username":document.getElementById('name').innerHTML},
            "dataSrc":function(result){
                return result;
            }
            },
            "columns":[
                {"data":"enterprise_drug_code"},
                {"data": "drug_name"},
                {"data": "drug_id"},
                {"data": "end_date"},
                {"data": "update_date"},
                {"data": "creation_date"},
                {"data": "state_of_drug"},
                {"data": "store_num"},
                {"data": "oid_seller"},
                {"data": "unit_price"},
                {"data": "oid_manufacturer"},
                {"data": "is_manufacturer_authorized"},
                {"data": "corresponding_state"},
                {"data":null}
            ],
            "columnDefs": [
                {
                    targets: 13,
                    render: function (a, b, c, d) {
                        var context =
                        {
                            func: [
                                {"name": "修改", "fn": "edit(\'" + c.enterprise_drug_code + "\',\'" + c.drug_name +  "\',\'" + c.drug_id +  "\',\'"  + c.end_date +  "\',\'" + c.update_date + "\',\'" + c.creation_date + "\',\'" + c.state_of_drug + "\',\'"  + c.store_num + "\',\'" + c.oid_seller + "\',\'" + c.unit_price + "\',\'" + c.oid_manufacturer + "\',\'" + "\')", "type": "primary"},
                                {"name": "删除", "fn": "del(\'" + c.enterprise_drug_code + "\')", "type": "danger"}
                            ]
                        };
                        //console.log(b.uid);
                        var html = template(context);
                        return html;
                    }
                }
 
            ],

            "dom": "<'row'<'col-md-2'l><'#mytool.col-md-4'><'col-md-6'f>r>"+
                    "t" +
                    "<'row'<'col-md-6'i><'col-md-6'p>>",
            "initComplete": function () {
                //$("#mytool").append('<button id="datainit" type="button" class="btn btn-primary btn-sm">增加基础数据</button>&nbsp');
                $("#mytool").append('<button type="button" class="btn btn-primary btn-sm" id="add_drug">添加新药品</button>');
                $("#add_drug").on("click", add_drug);
            }

            
         });
         $("#save").click(add);
         $("#save2").click(add2);
});

function add2() {
        var addJson = {
            "uid": $("#uid").val(),
            "role_name": $("#role_name").val(),
            "user_name": $("#user_name").val(),
            "password": $("#password").val(),
            "question": $("#question").val(),
            "answer": $("#answer").val(),
            "oid": $("#oid2").val(),
            "seller_info": $("#seller_info").val(),
            "buyer_info": $("#buyer_info").val(),
            "user_state": $("#user_state").val(),
            "user_authority": $("#user_authority").val(),
            "salt":$("#salt").val(),
            "is_organization_accept":$("#is_organization_accept").val()
        };
        // console.log(addJson);
        ajax2(addJson);
    }

    function add() {
        var addJson;
        if(editFlag){
            addJson = {
            "enterprise_drug_code": $("#enterprise_drug_code").val(),
            "drug_name": $("#drug_name").val(),
            "drug_id": $("#drug_id").val(),
            "end_date": $("#end_date").val(),
            "update_date": $("#update_date").val(),
            "creation_date": $("#creation_date").val(),
            "state_of_drug": $("#state_of_drug").val(),
            "store_num": $("#store_num").val(),
            "oid_seller": $("#oid_seller").val(),
            "unit_price": $("#unit_price").val(),
            "oid_manufacturer": $("#oid_manufacturer").val(),
            // "is_manufacturer_authorized": $("#is_manufacturer_authorized").val(),
             "corresponding_state": $("#corresponding_state").val(),
        }}
        else{
            addJson = {
            "drug_name": $("#drug_name").val(),
            "end_date": $("#end_date").val(),
            // "creation_date": $("#creation_date").val(),
            // "state_of_drug": $("#state_of_drug").val(),
            "store_num": $("#store_num").val(),
            "oid_seller": $("#oid_seller").val(),
            "unit_price": $("#unit_price").val(),
            "oid_manufacturer":$("#oid_manufacturer").val(),
            // "is_manufacturer_authorized": $("#is_manufacturer_authorized").val(),
             "corresponding_state": $("#corresponding_state").val(),
        }
        }
        // console.log(addJson);
        ajax(addJson);
    }

    function clear() {
        $("#enterprise_drug_code").val("").attr("disabled",true);
        $("#drug_name").val("");
        $("#drug_id").val("").attr("disabled",true);
        $("#end_date").val("");
        $("#update_date").val("").attr("disabled",true);
        $("#creation_date").val("").attr("disabled",true);
        $("#state_of_drug").val("").attr("disabled",true);
        $("#store_num").val("");
        $("#oid_seller").val("");
        $("#unit_price").val("");
        $("#oid_manufacturer").val("");
        // $("#is_manufacturer_authorized").val("");
         $("#corresponding_state").val("");
        editFlag = false;
    }

    function add_drug(){
        clear();
        $("#myModal").modal("show");
    }

    function edit(enterprise_drug_code,drug_name,drug_id,end_date,update_date,creation_date,state_of_drug,store_num, oid_seller, unit_price, oid_manufacturer,corresponding_state) {
        // console.log(uid);
        editFlag = true;
        $("#myModalLabel").text("修改");
        $("#enterprise_drug_code").val(enterprise_drug_code).attr("disabled",true);
        $("#drug_name").val(drug_name);
        $("#drug_id").val(drug_id).attr("disabled",true);
        $("#end_date").val(end_date);
        $("#update_date").val(update_date).attr("disabled",true);
        $("#creation_date").val(creation_date).attr("disabled",true);
        $("#state_of_drug").val(state_of_drug).attr("disabled",true);
        $("#store_num").val(store_num);
        $("#oid_seller").val(oid_seller);
        $("#unit_price").val(unit_price);
        $("#oid_manufacturer").val(oid_manufacturer);
        $("#corresponding_state").val(corresponding_state);
        $("#myModal").modal("show");
    }

    function edit2(uid,role_name,user_name,password,question,answer,oid,seller_info,buyer_info,user_state,user_authority,salt,is_organization_accept) {
        // console.log(uid);
        $("#uid").val(uid).attr("disabled",true);
        $("#role_name").val(role_name);
        $("#user_name").val(user_name);
        $("#password").val(password);
        $("#question").val(question);
        $("#answer").val(answer);
        $("#oid2").val(oid);
        $("#seller_info").val(seller_info);
        $("#buyer_info").val(buyer_info);
        $("#user_state").val(user_state);
        $("#user_authority").val(user_authority);
        $("#salt").val(salt).attr("disabled",true);
        $("#is_organization_accept").val(is_organization_accept);
        $("#myModal2").modal("show");
    }

    function ajax2(obj) {//用来修改用户信息
        var url ="http://210.30.97.103:20305/admin/users";
        var data={
                "uid": obj.uid,
                "role_name": obj.role_name,
                "user_name": obj.user_name,
                "password": obj.password,
                "question": obj.question,
                "answer": obj.answer,
                "oid": obj.oid,
                "seller_info": obj.seller_info,
                "buyer_info": obj.buyer_info,
                "user_state": obj.user_state,
                "user_authority": obj.user_authority,
                "salt": obj.salt,
                "is_organization_accept": obj.is_organization_accept
            };
        $.ajax({// 参照!
            "url":url,
            "type":"put",
            contentType: 'application/json;charset=utf-8',
            data: JSON.stringify(data),
            dataType:'json',
             success: function () {
                table.ajax.reload();
                $("#myModal").modal("hide");
                console.log(obj);
                alert("修改成功!")
            }
        });
    }

    function ajax(obj) {
        
        if(editFlag){
            url = "http://210.30.97.103:20305/admin/companydrug/update";

            data = {
                "enterprise_drug_code": obj.enterprise_drug_code,
                "drug_name": obj.drug_name,
                "drug_id": obj.drug_id,
                "end_date": obj.end_date,
                "update_date": obj.update_date,
                "creation_date": obj.creation_date,
                "state_of_drug": obj.state_of_drug,
                "store_num": obj.store_num,
                "oid_seller": obj.oid_seller,
                "unit_price": obj.unit_price,
                "oid_manufacturer": obj.oid_manufacturer,
                "corresponding_state": obj.corresponding_state,
                //"is_manufacturer_authorized":obj.is_manufacturer_authorized,
            }
            $.ajax({
            url:url ,
            "type":"put",
            contentType: 'application/json;charset=utf-8',
            data: JSON.stringify(data),
            dataType:'json',
             success: function (result) {
                table.ajax.reload();
                $("#myModal").modal("hide");
                $("#myModalLabel").text("更新");
                alert("更新成功");
                console.log("更新成功");
                }
            });
        }
        else{
            var url ="http://210.30.97.103:20305/admin/companydrug" ;
            var data =  {
                "drug_name": obj.drug_name,
                "end_date": obj.end_date,
                "store_num": obj.store_num,
                "oid_seller": obj.oid_seller,
                "unit_price": obj.unit_price,
                "oid_manufacturer": obj.oid_manufacturer,
                "corresponding_state": obj.corresponding_state,
            };
            $.ajax({
            url:url,
            "type":"post",
            contentType: 'application/json;charset=utf-8',
            data: JSON.stringify(data),
            dataType:'json',
             success: function (result) {
                table.ajax.reload();
                $("#myModal").modal("hide");
                $("#myModalLabel").text("添加");
                alert("添加成功");
                console.log("添加成功");
                }
            });
        }
    }

    function del(enterprise_drug_code) {
        $.ajax({
            url: "http://210.30.97.103:20305/admin/Companydrug",
            type: "delete",
        
            data: {
                "enterprise_drug_code": enterprise_drug_code
            }, success: function () {
                table.ajax.reload();
                alert("删除成功");
                console.log("删除成功");
            }
        });
    }

</script>

<script type="text/javascript">
    var url=decodeURI(location.href);
    var num=url.indexOf("?");
    var str=url.substr(num+1);
    $("#name").html(""+str);
</script>

<script src="js/myAjax.js"></script>
<script>
    $("#settings").click(function(ev){
        myajax({
                    type:"get",
                    url:"http://210.30.97.103:20305/seller/getUserInfoByUserName",//DONE:查看管理员的信息完成
                    data:{
                        "username":document.getElementById('name').innerHTML
                    },
                    success: function (xhr) {
                        // console.log(xhr.responseText);
                        var result = xhr.responseText;
                        /*
                        在低版本的IE中, 不可以使用原生的JSON.parse方法, 但是可以使用json2.js这个框架来兼容
                        */
                        var obj = JSON.parse(result);
                        edit2(obj.uid,obj.role_name,obj.user_name,obj.password,obj.question,obj.answer,obj.oid,obj.seller_info,obj.buyer_info,obj.user_state,obj.user_authority,obj.salt,obj.is_organization_accept);
                    },
                    error: function (xhr) {
                        alert(xhr.status);
                    }
                });
    })
</script>

<script>
    $("#request").click(function(ev){
        console.log($("#name").val());
        window.location.href="registeration_request.html?"+document.getElementById('name').innerHTML+"";
    })
</script>

<script>
    $("#management").click(function(ev){
        console.log($("#name").val());
        window.location.href="org_manager.html?"+document.getElementById('name').innerHTML+"";
    })
</script>

<script>
    $("#medical").click(function(ev){
        console.log($("#name").val());
        window.location.href="medical_manager.html?"+document.getElementById('name').innerHTML+"";
    })
</script>

<script>
    $("#buyer_application").click(function(ev){
        console.log($("#name").val());
        window.location.href="buyer_application.html?"+document.getElementById('name').innerHTML+"";
    })
</script>

</body>
</html>